<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>修改角色</title>
<link href="${ctx }/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="${ctx }/js/niceValidator/jquery.validator.css" />
<link href="${ctx }/css/jquery.multiSelect.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx }/js/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="${ctx }/js/layer/layer.js"></script>
<script type="text/javascript" src="${ctx }/js/niceValidator/jquery.validator.js"></script>
<script type="text/javascript" src="${ctx }/js/niceValidator/local/zh_CN.js"></script>
<script type="text/javascript" src="${ctx }/js/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="${ctx }/js/jquery.multiSelect.js"></script>

<script>
	$(document).ready(function(){
		$("#submitBtn").click(function(){
			submitForms();
		});
		$("#rIdSel").multiSelect({
	        selectAll: false,
	        noneSelected: '请选择角色',
	        oneOrMoreSelected: '*'
	    });
	    
	});
	var index = parent.layer.getFrameIndex(window.name);
	//修改角色
	function submitForms(){
		var rIds=$("#rIdSel").selectedValuesString();
		if(rIds==''){
			layer.alert('请选择角色', {icon: 2});
			return;
		}
		var loadi = layer.load();
		$("#roleIds").val(rIds);
		var datajson=$("#submitForm").serialize();
		$.ajax({
			type:"POST",
			url:"${ctx}/sysman/admin/editRole.do",
			data:datajson,
			dataType:"json",
			success:function(data){
				layer.close(loadi);
				if(data.status=='SUCCESS'){
					window.parent.searchQuery('Refresh');
					window.parent.bottomMsgOpen('修改成功');
					window.parent.layer.close(index);
				}else{
					layer.alert(data.msg);
				}
			}
		});
	}
</script>
<style type="text/css">
	HTML {
		font-family: Arial, Helvetica, sans-serif;
		font-size: 12px;
	}
	
	H2 {
		font-size: 14px;
		font-weight: bold;
		margin: 1em 0em .25em 0em;
	}
	
	P {
		margin: 1em 0em;
	}
</style>
</head>
<body style="min-width:600px;">
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="#">系统管理</a></li>
    <li><a href="#">用户管理</a></li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>修改用户【${admin.systemUserName}】角色</span></div>
<form id="submitForm">	
  <ul class="forminfo">
    <li>
      <label>角色</label>
      <input type="hidden" name="rId" id="roleIds" />
      <select multiple="multiple" id="rIdSel" style="width:334px;">
      	<c:forEach items="${roleList}" var="item">
      		<option value="${item.rId }" <c:if test="${fn:contains(adminRole.role.rId, item.rId)}">selected="selected"</c:if>>${item.rName }</option>
      	</c:forEach>
      </select>
    </li>
    <li>
      <label>&nbsp;</label>
      <input type="hidden" name="systemCode" value="${systemAdmin.systemCode }" />
      <input name="" id="submitBtn" type="button" class="btn" value="确认保存"/>
    </li>
  </ul>
</form>
</div>
</body>
</html>

 